//////////////////////////////////////////////////////////////////////////////
//
// File:  parser.h
//
// Description:
//   This class parses a config file for the configuration needed for the 
//   bnet connection, and chat clients and server.
//
// It utilizes a LL of lineInfo objects and searches through that to retrieve
// requested datavalues.
//
#ifndef PARSER_H
#define PARSER_H

#include <fstream>
#include <iostream>
#include <list>
#include <string.h>

using namespace std;


//
// Helper class for the parser class.  It just holds the config info for
// 1 line in the config file.
//

class lineInfo {
 public:
  string key;
  string value;
};


//
// Parser class assists in parsing a config file.
//
class parser {
 public:
  parser();
  parser(string file);  // Calls parse()
  ~parser();            // closes file streams if open and clears configInfo
  bool parse(string file);  // Parses the file.

  bool fetch(string key, string &value);  // Fetches the value of a key.
  bool fetch(string key, bool &value);
  bool fetch(string key, int &value);
 private:
  ifstream toParse;
  list <lineInfo> configInfo;  // used to store all the config info.

};

#endif
